package com.ssy.lingxi.order.model.vo.mobile.response;

import com.ssy.lingxi.common.constant.order.OrderPayChannelEnum;
import com.ssy.lingxi.common.constant.order.OrderPayTypeEnum;
import com.ssy.lingxi.order.model.constant.BuyerInnerStatusEnum;
import com.ssy.lingxi.order.model.constant.OrderOuterStatusEnum;
import com.ssy.lingxi.order.model.constant.OrderServiceContants;
import com.ssy.lingxi.order.utils.NumberUtil;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

/**
 * App - 订单详情 - 订单支付信息
 * @author 万宁
 * @version 2.0.0
 * @date 2021-09-25
 */
public class MobileOrderPaymentDetailVO implements Serializable {
    private static final long serialVersionUID = 8400246161437142140L;

    public MobileOrderPaymentDetailVO(Integer tag, Long paymentId, LocalDateTime payTime, Integer fundMode, Integer payBatchNo, Integer batchNo, Integer payType, Integer payChannel, String payNode, Integer innerStatus, BigDecimal payRate, BigDecimal payAmount, List<String> vouchers) {
        this.tag = tag;
        this.paymentId = paymentId;
        this.payTime = payTime == null ? "" : payTime.format(OrderServiceContants.DEFAULT_TIME_FORMATTER);
        this.showPay = payBatchNo.equals(batchNo);
        this.fundMode = fundMode;
        this.batchNo = batchNo;
        this.payType = payType;
        this.payTypeName = OrderPayTypeEnum.getNameByCode(payType);
        this.payChannel = payChannel;
        this.payChannelName = OrderPayChannelEnum.getNameByCode(payChannel);
        this.payNode = payNode;
        this.innerStatus = innerStatus;
        this.innerStatusName = BuyerInnerStatusEnum.getNameByCode(innerStatus);
        this.payRate = NumberUtil.formatPayRate(payRate);
        this.payAmount = NumberUtil.formatAmount(payAmount);
        this.vouchers = vouchers;
        this.outerStatus = 0;
        this.outerStatusName = "";
    }

    public MobileOrderPaymentDetailVO(Integer tag, Long paymentId, LocalDateTime payTime, Integer fundMode, Integer payBatchNo, Integer batchNo, Integer payType, Integer payChannel, String payNode, Integer innerStatus, Integer outerStatus, BigDecimal payRate, BigDecimal payAmount, List<String> vouchers) {
        this.tag = tag;
        this.paymentId = paymentId;
        this.payTime = payTime == null ? "" : payTime.format(OrderServiceContants.DEFAULT_TIME_FORMATTER);
        this.showPay = payBatchNo.equals(batchNo);
        this.fundMode = fundMode;
        this.batchNo = batchNo;
        this.payType = payType;
        this.payTypeName = OrderPayTypeEnum.getNameByCode(payType);
        this.payChannel = payChannel;
        this.payChannelName = OrderPayChannelEnum.getNameByCode(payChannel);
        this.payNode = payNode;
        this.innerStatus = innerStatus;
        this.innerStatusName = BuyerInnerStatusEnum.getNameByCode(innerStatus);
        this.outerStatus = outerStatus;
        this.outerStatusName = OrderOuterStatusEnum.getNameByCode(outerStatus);
        this.payRate = NumberUtil.formatPayRate(payRate);
        this.payAmount = NumberUtil.formatAmount(payAmount);
        this.vouchers = vouchers;
    }

    /**
     * 标签，表示“第x次”支付
     */
    private Integer tag;

    /**
     * 支付记录Id
     */
    private Long paymentId;

    /**
     * 支付时间，格式为yyyy-MM-dd HH:mm:ss，如未支付则为空字符串
     */
    private String payTime;

    /**
     * 是否可以支付，前端要根据此字段判断是否可以支付
     */
    private Boolean showPay;

    /**
     * 资金归集模式，如果需要支付，调用支付接口时需要传递此参数
     */
    private Integer fundMode;

    /**
     * 支付次数，如果需要支付，调用支付接口时需要传递此参数
     */
    private Integer batchNo;

    /**
     * 支付方式枚举，如果需要支付，调用支付接口时需要传递此参数
     */
    private Integer payType;

    /**
     * 支付方式名称
     */
    private String payTypeName;

    /**
     * 支付渠道枚举，如果需要支付，调用支付接口时需要传递此参数
     */
    private Integer payChannel;

    /**
     * 支付渠道名称
     */
    private String payChannelName;

    /**
     * 支付环节
     */
    private String payNode;

    /**
     * 内部状态枚举
     */
    private Integer innerStatus;

    /**
     * 内部状态名称
     */
    private String innerStatusName;

    /**
     * 外部状态
     */
    private Integer outerStatus;

    /**
     * 外部状态名称
     */
    private String outerStatusName;

    /**
     * 支付比例，百分比分子部分
     */
    private String payRate;

    /**
     * 支付金额，保留两位小数
     */
    private String payAmount;

    /**
     * 支付凭证文件Url列表
     */
    private List<String> vouchers;

    public Integer getTag() { return tag; }

    public void setTag(Integer tag) { this.tag = tag; }

    public Long getPaymentId() {
        return paymentId;
    }

    public void setPaymentId(Long paymentId) {
        this.paymentId = paymentId;
    }

    public String getPayTime() {
        return payTime;
    }

    public void setPayTime(String payTime) {
        this.payTime = payTime;
    }

    public Boolean getShowPay() {
        return showPay;
    }

    public void setShowPay(Boolean showPay) {
        this.showPay = showPay;
    }

    public Integer getFundMode() {
        return fundMode;
    }

    public void setFundMode(Integer fundMode) {
        this.fundMode = fundMode;
    }

    public Integer getBatchNo() {
        return batchNo;
    }

    public void setBatchNo(Integer batchNo) {
        this.batchNo = batchNo;
    }

    public Integer getPayType() {
        return payType;
    }

    public void setPayType(Integer payType) {
        this.payType = payType;
    }

    public String getPayTypeName() {
        return payTypeName;
    }

    public void setPayTypeName(String payTypeName) {
        this.payTypeName = payTypeName;
    }

    public Integer getPayChannel() {
        return payChannel;
    }

    public void setPayChannel(Integer payChannel) {
        this.payChannel = payChannel;
    }

    public String getPayChannelName() {
        return payChannelName;
    }

    public void setPayChannelName(String payChannelName) {
        this.payChannelName = payChannelName;
    }

    public String getPayNode() {
        return payNode;
    }

    public void setPayNode(String payNode) {
        this.payNode = payNode;
    }

    public Integer getInnerStatus() {
        return innerStatus;
    }

    public void setInnerStatus(Integer innerStatus) {
        this.innerStatus = innerStatus;
    }

    public String getInnerStatusName() {
        return innerStatusName;
    }

    public void setInnerStatusName(String innerStatusName) {
        this.innerStatusName = innerStatusName;
    }

    public Integer getOuterStatus() {
        return outerStatus;
    }

    public void setOuterStatus(Integer outerStatus) {
        this.outerStatus = outerStatus;
    }

    public void setOuterStatusName(String outerStatusName) {
        this.outerStatusName = outerStatusName;
    }

    public String getPayRate() {
        return payRate;
    }

    public void setPayRate(String payRate) {
        this.payRate = payRate;
    }

    public String getPayAmount() {
        return payAmount;
    }

    public void setPayAmount(String payAmount) {
        this.payAmount = payAmount;
    }

    public List<String> getVouchers() {
        return vouchers;
    }

    public void setVouchers(List<String> vouchers) {
        this.vouchers = vouchers;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        MobileOrderPaymentDetailVO that = (MobileOrderPaymentDetailVO) o;
        return Objects.equals(paymentId, that.paymentId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(paymentId);
    }
}
